<?php
header("Content-Type:json/html;charset=utf8;");

$config = require '../config.php';
$article_id = $_POST['id'];
$conn = new mysqli($config['servername'], $config['username'], $config['password'], $config['dbname']);
$sql = "select a.*,c.category from article as a,category as c where a.id = '$article_id' and category_id = c.id";
$result = $conn->query($sql);
$conn->close();

if($result->num_rows>=1){
    $data = array();
    while ($row = $result->fetch_assoc())
    {
        $data[] = $row;
    }
    $result = ['code' =>1, 'data' => $data,  'msg' => "获取文章详情成功!"];
}else{
    $result = ['code' =>0,  'msg' => "获取文章详情失败!"];
}
print_r(json_encode($result));
